<template>
  <j-modal
    :title="title"
    width="50%"
    :visible="value"
    fullscreen
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    :cancelText="$t('button.closeTxt')"
    @cancel="handleCancel"
  >
    <outboundFrom v-if="value" ref="form" :disableSubmit="disableSubmit" @ok="handleOk"></outboundFrom>

    <template #footer>
      <a-button v-if="!disableSubmit" type="primary" @click="handleSave">{{ $t('button.saveTxt') }}</a-button>
      <a-button v-if="!disableSubmit" type="primary" @click="handleSubmit">{{ $t('button.submitTxt') }}</a-button>

      <a-button @click="handleCancel">{{ $t('button.closeTxt') }}</a-button>
    </template>
  </j-modal>
</template>

<script>
import outboundFrom from './outboundFrom.vue'
export default {
  desc: '在制品入库单申请弹窗',
  name: 'InboundApplyModal',
  components: { outboundFrom },
  props: {
    value: {
      type: Boolean,
      default: false
    },
    disableSubmit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      toExamine: false,
      title: '新增',
      record: {}
    }
  },
  methods: {
    handleReject() {
      this.$emit('handleReject', record)
    },

    handlePass() {
      this.$emit('handlePass', record)
    },

    handleSave() {
      this.$refs.form.submit(10)
    },

    handleSubmit() {
      this.$refs.form.submit(20)
    },
    handleOk() {
      this.$emit('ok')
    },
    handleDetail(record, isAuth) {
      if (isAuth) {
        this.toExamine = true
      } else {
        this.toExamine = false
      }
      this.title = '入库单详情'
      this.record = record
      this.$nextTick(() => {
        this.$refs.form.handleDetail(record)
      })
    },
    handleCancel() {
      this.$emit('input', false)
      this.$emit('handleCancel')
    },
    edit(item) {
      this.title = '入库单编辑'
      this.toExamine = true
      this.$nextTick(() => {
        this.$refs.form.edit(item)
      })
    }
  }
}
</script>

<style lang="less" scoped></style>
